using PathologicalGames;
using Spine;
using Spine.Unity;
using UnityEngine;
using UnityEngine.SceneManagement;

public class ShopController : MonoBehaviour
{
	private readonly string[] AnimationName = new string[3]
	{
		"idle",
		"skill1",
		"skill2"
	};

	private readonly string[][] SpriteWeapon = new string[10][]
	{
		new string[6]
		{
			"icon_nam dam a",
			"icon_nam dam a",
			"icon_nam dam b",
			"icon_nam dam c",
			"icon_nam dam d",
			"icon_nam dam e"
		},
		new string[6]
		{
			"items_stick1",
			"items_stick1",
			"items_stick2",
			"items_stick3",
			"items_stick4",
			"items_stick5"
		},
		new string[6]
		{
			"items_claw1",
			"items_claw1",
			"items_claw2",
			"items_claw3",
			"items_claw4",
			"items_claw5"
		},
		new string[6]
		{
			"items_dai dao1",
			"items_dai dao1",
			"items_dai dao2",
			"items_dai dao3",
			"items_dai dao4",
			"items_dai dao5"
		},
		new string[6]
		{
			"icon_kiem a",
			"icon_kiem a",
			"icon_kiem b",
			"icon_kiem c",
			"icon_kiem d",
			"icon_kiem e"
		},
		new string[6]
		{
			"icon_dao a",
			"icon_dao a",
			"icon_dao b",
			"icon_dao c",
			"icon_dao d",
			"icon_dao e"
		},
		new string[6]
		{
			"icon_cung a",
			"icon_cung a",
			"icon_cung b",
			"icon_cung c",
			"icon_cung d",
			"icon_cung e"
		},
		new string[6]
		{
			"items_kich1",
			"items_kich1",
			"items_kich2",
			"items_kich3",
			"items_kich4",
			"items_kich5"
		},
		new string[6]
		{
			"items_axe1",
			"items_axe1",
			"items_axe2",
			"items_axe3",
			"items_axe4",
			"items_axe5"
		},
		new string[6]
		{
			"items_zed1",
			"items_zed1",
			"items_zed2",
			"items_zed3",
			"items_zed4",
			"items_zed5"
		}
	};

	private int[][] numberUpgradeWeapon = new int[10][]
	{
		new int[7]
		{
			0,
			5000,
			12000,
			30000,
			50000,
			120000,
			0
		},
		new int[7]
		{
			9000,
			2000,
			3000,
			4000,
			6000,
			8000,
			0
		},
		new int[7]
		{
			20000,
			5000,
			7000,
			10000,
			12000,
			15000,
			0
		},
		new int[7]
		{
			40000,
			10000,
			14000,
			19000,
			24000,
			25000,
			0
		},
		new int[7]
		{
			85000,
			15000,
			28000,
			32000,
			38000,
			45000,
			0
		},
		new int[7]
		{
			170000,
			30000,
			40000,
			55000,
			75000,
			90000,
			0
		},
		new int[7]
		{
			300000,
			50000,
			70000,
			95000,
			110000,
			140000,
			0
		},
		new int[7]
		{
			350000,
			70000,
			90000,
			110000,
			140000,
			180000,
			0
		},
		new int[7]
		{
			420000,
			100000,
			120000,
			140000,
			180000,
			250000,
			0
		},
		new int[7]
		{
			550000,
			120000,
			160000,
			200000,
			250000,
			350000,
			0
		}
	};

	private string[][] damageVukhi = new string[10][]
	{
		new string[6]
		{
			"0%",
			"10%",
			"25%",
			"45%",
			"70%",
			"100%"
		},
		new string[6]
		{
			"150",
			"300",
			"450",
			"600",
			"850",
			"1050"
		},
		new string[6]
		{
			"650",
			"800",
			"1100",
			"1400",
			"1700",
			"2100"
		},
		new string[6]
		{
			"1500",
			"1900",
			"2500",
			"3300",
			"4300",
			"5500"
		},
		new string[6]
		{
			"4000",
			"5000",
			"6500",
			"8000",
			"9500",
			"11500"
		},
		new string[6]
		{
			"7500",
			"9000",
			"12500",
			"14000",
			"17000",
			"20000"
		},
		new string[6]
		{
			"16000",
			"20000",
			"25000",
			"32000",
			"40000",
			"50000"
		},
		new string[6]
		{
			"24000",
			"32000",
			"42000",
			"52000",
			"62000",
			"75000"
		},
		new string[6]
		{
			"33000",
			"45000",
			"58000",
			"72000",
			"85000",
			"100000"
		},
		new string[6]
		{
			"45000",
			"60000",
			"75000",
			"95000",
			"115000",
			"140000"
		}
	};

	private readonly string[] GameobjectName = new string[11]
	{
		"btn-back",
		"upweapon",
		"downitem",
		"downgold",
		"scroll",
		"content-item1",
		"content-item2",
		"content-item3",
		"addcoin",
		"btnClose",
		"content-item4"
	};

	[Header("---Prefab GameObject---")]
	public GameObject[] Sticks;

	[Header("---Inspector GameObject---")]
	public GameObject DemoTable;

	[Header("---Privte Variable---")]
	private SpawnPool pool;

	private int id;

	private int a;

	private int c;

	private string currentAnimationName;

	private bool isClickDemo;

	private GameObject currentDemoStick;

	private SkeletonAnimation skeletonAnimation;

	public GameObject[] SpriteMax;

	public GameObject[] CoinMax;

	public tk2dTextMesh texhMeshTotalCoin;

	public GameObject[] HandTutorial;

	public GameObject[] systemAllShop;

	public GameObject[] btnAllShopON;

	public GameObject[] btnAllShopOFF;

	public GameObject[] systemtheoShop;

	public GameObject[] WeaponUp;

	public GameObject[] WeaponDown;

	public GameObject[] ItemUp;

	public GameObject[] ItemDown;

	public GameObject[] GoldUp;

	public GameObject[] GoldDown;

	public GameObject[] UpgradeAnimation;

	public tk2dTextMesh[] texhMeshCoinUpgrade;

	public tk2dTextMesh[] damageweapon;

	public tk2dTextMesh[] lvVukhi;

	public GameObject[] Lockkhoa;

	public tk2dSprite[] imgWeapon;

	public GameObject EquipOneWeapon;

	public GameObject btnQuipWeapon;

	private int indexbtnSHop;

	public GameObject SystemUpgrade;

	public GameObject SystemItem;

	public tk2dTextMesh texhMeshCoinUpgradeInDialog;

	public tk2dSprite ImageUpgradeNow;

	public tk2dSprite ImageUpgradeNext;

	public tk2dTextMesh texhMeshNow;

	public tk2dTextMesh texhMeshHealth;

	public tk2dTextMesh texhMeshHealthMax;

	public tk2dTextMesh texhMeshNext;

	public GameObject btnBuyWeapon;

	private string[] DesUpgrade = new string[5]
	{
		"INCREASE 10% DAMAGE OF PLAYER",
		"INCREASE 25% DAMAGE OF PLAYER",
		"INCREASE 45% DAMAGE OF PLAYER",
		"INCREASE 70% DAMAGE OF PLAYER",
		"INCREASE 100% DAMAGE OF PLAYER"
	};

	private string[] DesUpgrade1 = new string[9]
	{
		"INCREASE DAMAGE OF THE STAFF",
		"INCREASE DAMAGE OF THE CLAW",
		"INCREASE DAMAGE OF THE GUAN DAO",
		"INCREASE DAMAGE OF THE SWORD",
		"INCREASE DAMAGE OF THE CLOUD SWORD",
		"INCREASE DAMAGE OF THE CROSSBOW",
		"INCREASE DAMAGE OF THE PIKE",
		"INCREASE DAMAGE OF THE AXE",
		"INCREASE DAMAGE OF THE ZED"
	};

	public tk2dTextMesh texhMeshDesUpgrade;

	public tk2dTextMesh priceItemInDialog;

	public tk2dTextMesh DesItemInDialog;

	public tk2dSprite ImageBuyItem;

	public GameObject Tinker;

	public GameObject Dog;

	public GameObject[] CoinTinkerAndCoinDog;

	private int tutorialShop;

	public GameObject CoinAnHien;

	private string[] imageItem = new string[4]
	{
		"items_blood a",
		"items_blood b",
		"item_dog",
		"items_tingker bell"
	};

	private string[] numberPriceItem = new string[4]
	{
		"1000",
		"5000",
		"100000",
		"19,99$"
	};

	private string[] DesPriceItem = new string[4]
	{
		"INCREASE 4000 HEALTH",
		"INCREASE 20000 HEALTH",
		"DOG - AUTOMATIC PICK COINS AND INCREASE 20% COINS DROP ",
		"AN ANGEL - INCREASE 15% HEALTH MAX AND BUFF 2% HEALTH MAX"
	};

	private Vector3[] posWeapon = new Vector3[10]
	{
		new Vector3(0.4f, -1.05f, 0f),
		new Vector3(0.4f, -2.13f, 0f),
		new Vector3(0.4f, -3.16f, 0f),
		new Vector3(0.4f, -4.22f, 0f),
		new Vector3(0.4f, -5.3f, 0f),
		new Vector3(0.4f, -6.35f, 0f),
		new Vector3(0.4f, -7.41f, 0f),
		new Vector3(0.4f, -8.48f, 0f),
		new Vector3(0.4f, -9.55f, 0f),
		new Vector3(0.4f, -10.64f, 0f)
	};

	private static bool _isInited;

	public const string _7000gold = "com.ffs.stickman.ghost.warrior.7000golds";

	public const string _40000gold = "com.ffs.stickman.ghost.warrior.40000golds";

	public const string _90000gold = "com.ffs.stickman.ghost.warrior.90000golds";

	public const string _200000gold = "com.ffs.stickman.ghost.warrior.200000golds";

	public const string _450000gold = "com.ffs.stickman.ghost.warrior.450000golds";

	public const string _fairy = "com.ffs.stickman.ghost.warrior.fairy";

	private void Start()
	{
		Time.timeScale = 1f;
		id = GameManager.indexVukhi;
		pool = base.gameObject.GetComponent<SpawnPool>();
		currentDemoStick = pool.Spawn(Sticks[id].transform, DemoTable.transform.position - new Vector3(-0.65f, 1.5f, 0f), Quaternion.identity, DemoTable.transform).gameObject;
		EquipOneWeapon.transform.localPosition = posWeapon[id];
		if (GameManager.Tutorial == 1)
		{
			for (int i = 0; i < GameobjectName.Length - 1; i++)
			{
				GameObject.Find(GameobjectName[i]).GetComponent<Collider>().enabled = false;
			}
			HandTutorial[0].SetActive(value: true);
		}
		if (GameManager.Tutorial == 3 && GameManager.TotalCoin >= 9000)
		{
			for (int j = 0; j < GameobjectName.Length; j++)
			{
				GameObject.Find(GameobjectName[j]).GetComponent<Collider>().enabled = false;
			}
			GameObject.Find("content-item2").GetComponent<Collider>().enabled = true;
			HandTutorial[4].SetActive(value: true);
		}
		for (int k = 0; k < texhMeshCoinUpgrade.Length; k++)
		{
			texhMeshCoinUpgrade[k].text = numberUpgradeWeapon[k][GameManager.levelUpgrade[k] + 1].ToString();
			texhMeshCoinUpgrade[k].Commit();
			if (GameManager.levelUpgrade[k] == 5)
			{
				SpriteMax[k].SetActive(value: true);
				CoinMax[k].SetActive(value: false);
			}
		}
		for (int l = 0; l < 10; l++)
		{
			if (l == id)
			{
				WeaponUp[l].SetActive(value: true);
				WeaponDown[l].SetActive(value: false);
			}
			else
			{
				WeaponUp[l].SetActive(value: false);
				WeaponDown[l].SetActive(value: true);
			}
		}
	}

	private void Update()
	{
		texhMeshTotalCoin.text = GameManager.TotalCoin.ToString();
		texhMeshHealth.text = GameManager.numberHealth.ToString();
		texhMeshHealthMax.text = GameManager.numberBigHealth.ToString();
		if (GameManager.levelUpgrade[id] > -1 && id != GameManager.indexVukhi)
		{
			btnQuipWeapon.SetActive(value: true);
		}
		else
		{
			btnQuipWeapon.SetActive(value: false);
		}
		if (GameManager.Tinker > 0)
		{
			Tinker.SetActive(value: true);
			CoinTinkerAndCoinDog[1].SetActive(value: false);
		}
		if (GameManager.Dog > 0)
		{
			Dog.SetActive(value: true);
			CoinTinkerAndCoinDog[0].SetActive(value: false);
		}
		for (int i = 0; i < GameManager.levelUpgrade.Length; i++)
		{
			if (GameManager.levelUpgrade[i] >= 0)
			{
				Lockkhoa[i].SetActive(value: false);
				damageweapon[i].text = damageVukhi[i][GameManager.levelUpgrade[i]];
				damageweapon[i].Commit();
				lvVukhi[i].text = (GameManager.levelUpgrade[i] + 1).ToString();
				lvVukhi[i].Commit();
				if (GameManager.levelUpgrade[i] == 5)
				{
					SpriteMax[i].SetActive(value: true);
					CoinMax[i].SetActive(value: false);
					UpgradeAnimation[i].SetActive(value: false);
				}
				if (GameManager.TotalCoin >= numberUpgradeWeapon[i][GameManager.levelUpgrade[i] + 1] && GameManager.levelUpgrade[i] < 5)
				{
					UpgradeAnimation[i].SetActive(value: true);
				}
				else
				{
					UpgradeAnimation[i].SetActive(value: false);
				}
			}
			if (i > 0 && GameManager.levelUpgrade[i] >= 0)
			{
				imgWeapon[i - 1].SetSprite(SpriteWeapon[i][GameManager.levelUpgrade[i]]);
			}
		}
	}

	public void onClickBack()
	{
		AudioController.Instance.SoundButtonAllGame();
		Invoke("LoadMap", 0.4f);
	}

	private void LoadMap()
	{
		SceneManager.LoadScene("SelectMap");
	}

	public void onClickWeaponList(tk2dUIItem uiitem)
	{
		AudioController.Instance.SoundButtonAllGame();
		if (!isClickDemo)
		{
			id = uiitem.gameObject.GetComponent<SelectItem>().index;
			for (int i = 0; i < 10; i++)
			{
				if (i == id)
				{
					WeaponUp[i].SetActive(value: true);
					WeaponDown[i].SetActive(value: false);
				}
				else
				{
					WeaponUp[i].SetActive(value: false);
					WeaponDown[i].SetActive(value: true);
				}
			}
			if (id != GameManager.indexVukhi)
			{
				btnQuipWeapon.SetActive(value: true);
			}
			else
			{
				btnQuipWeapon.SetActive(value: false);
			}
			pool.DespawnAll();
			switch (id)
			{
			case 0:
				currentDemoStick = pool.Spawn(Sticks[0].transform, DemoTable.transform.position - new Vector3(-0.65f, 1.5f, 0f), Quaternion.identity, DemoTable.transform).gameObject;
				break;
			case 1:
				currentDemoStick = pool.Spawn(Sticks[1].transform, DemoTable.transform.position - new Vector3(-0.65f, 1.5f, 0f), Quaternion.identity, DemoTable.transform).gameObject;
				break;
			case 2:
				currentDemoStick = pool.Spawn(Sticks[2].transform, DemoTable.transform.position - new Vector3(-0.65f, 1.5f, 0f), Quaternion.identity, DemoTable.transform).gameObject;
				break;
			case 3:
				currentDemoStick = pool.Spawn(Sticks[3].transform, DemoTable.transform.position - new Vector3(-0.65f, 1.5f, 0f), Quaternion.identity, DemoTable.transform).gameObject;
				break;
			case 4:
				currentDemoStick = pool.Spawn(Sticks[4].transform, DemoTable.transform.position - new Vector3(-0.65f, 1.5f, 0f), Quaternion.identity, DemoTable.transform).gameObject;
				break;
			case 5:
				currentDemoStick = pool.Spawn(Sticks[5].transform, DemoTable.transform.position - new Vector3(-0.65f, 1.5f, 0f), Quaternion.identity, DemoTable.transform).gameObject;
				break;
			case 6:
				currentDemoStick = pool.Spawn(Sticks[6].transform, DemoTable.transform.position - new Vector3(-0.65f, 1.5f, 0f), Quaternion.identity, DemoTable.transform).gameObject;
				break;
			case 7:
				currentDemoStick = pool.Spawn(Sticks[7].transform, DemoTable.transform.position - new Vector3(-0.65f, 1.5f, 0f), Quaternion.identity, DemoTable.transform).gameObject;
				break;
			case 8:
				currentDemoStick = pool.Spawn(Sticks[8].transform, DemoTable.transform.position - new Vector3(-0.65f, 1.5f, 0f), Quaternion.identity, DemoTable.transform).gameObject;
				break;
			case 9:
				currentDemoStick = pool.Spawn(Sticks[9].transform, DemoTable.transform.position - new Vector3(-0.65f, 1.5f, 0f), Quaternion.identity, DemoTable.transform).gameObject;
				break;
			}
			if (GameManager.levelUpgrade[id] > -1)
			{
				btnBuyWeapon.SetActive(value: false);
			}
			else
			{
				btnBuyWeapon.SetActive(value: true);
			}
		}
		if (GameManager.Tutorial == 3 && GameManager.TotalCoin > 9000 && tutorialShop == 0)
		{
			tutorialShop++;
			HandTutorial[4].SetActive(value: false);
			HandTutorial[5].SetActive(value: true);
		}
	}

	public void EquipMentWeapon()
	{
		if (GameManager.levelUpgrade[id] > -1)
		{
			GameManager.indexVukhi = id;
			EquipOneWeapon.transform.localPosition = posWeapon[id];
			btnQuipWeapon.SetActive(value: false);
		}
		if (GameManager.Tutorial == 4)
		{
			GameManager.Tutorial++;
			HandTutorial[6].SetActive(value: false);
			for (int i = 0; i < GameobjectName.Length; i++)
			{
				GameObject.Find(GameobjectName[i]).GetComponent<Collider>().enabled = true;
			}
		}
	}

	public void onClickItemList(tk2dUIItem uiitem)
	{
		AudioController.Instance.SoundButtonAllGame();
		c = uiitem.gameObject.GetComponent<SelectItem>().index;
		for (int i = 0; i < 4; i++)
		{
			if (i == c)
			{
				ItemUp[i].SetActive(value: true);
				ItemDown[i].SetActive(value: false);
			}
			else
			{
				ItemUp[i].SetActive(value: false);
				ItemDown[i].SetActive(value: true);
			}
		}
	}

	public void onClickGoldList(tk2dUIItem uiitem)
	{
		AudioController.Instance.SoundButtonAllGame();
		a = uiitem.gameObject.GetComponent<SelectItem>().index;
		for (int i = 0; i < 5; i++)
		{
			if (i == a)
			{
				GoldUp[i].SetActive(value: true);
				GoldDown[i].SetActive(value: false);
			}
			else
			{
				GoldUp[i].SetActive(value: false);
				GoldDown[i].SetActive(value: true);
			}
		}
	}

	private void SetAnimation(bool isLoop)
	{
		skeletonAnimation.state.SetAnimation(0, AnimationName[Random.Range(0, AnimationName[id].Length)], isLoop);
	}

	public void onClickDemoTable()
	{
		AudioController.Instance.SoundButtonAllGame();
		if (currentDemoStick != null && !isClickDemo)
		{
			isClickDemo = true;
			skeletonAnimation = currentDemoStick.GetComponent<SkeletonAnimation>();
			skeletonAnimation.state.Complete += AnimationComplete;
			string text = AnimationName[Random.Range(1, 3)];
			while (currentAnimationName == text)
			{
				text = AnimationName[Random.Range(1, 3)];
			}
			currentAnimationName = text;
			skeletonAnimation.state.SetAnimation(0, text, loop: false);
		}
	}

	private void AnimationComplete(TrackEntry entry)
	{
		isClickDemo = false;
		skeletonAnimation.state.SetAnimation(0, AnimationName[0], loop: true);
		skeletonAnimation.state.Complete -= AnimationComplete;
	}

	public void OnClickUpgrade()
	{
		AudioController.Instance.SoundButtonAllGame();
		if (GameManager.levelUpgrade[id] < 5)
		{
			ImageUpgradeNow.SetSprite(SpriteWeapon[id][GameManager.levelUpgrade[id]]);
			ImageUpgradeNext.SetSprite(SpriteWeapon[id][GameManager.levelUpgrade[id] + 1]);
			texhMeshCoinUpgradeInDialog.text = numberUpgradeWeapon[id][GameManager.levelUpgrade[id] + 1].ToString();
			texhMeshCoinUpgradeInDialog.Commit();
			texhMeshNow.text = (GameManager.levelUpgrade[id] + 1).ToString();
			texhMeshNow.Commit();
			texhMeshNext.text = (GameManager.levelUpgrade[id] + 2).ToString();
			texhMeshNext.Commit();
			if (id == 0)
			{
				texhMeshDesUpgrade.text = DesUpgrade[GameManager.levelUpgrade[id]];
				texhMeshDesUpgrade.Commit();
			}
			else
			{
				texhMeshDesUpgrade.text = DesUpgrade1[id - 1];
			}
			SystemUpgrade.transform.position = Vector3.zero;
		}
		if (GameManager.Tutorial == 1 && tutorialShop == 0)
		{
			tutorialShop++;
			HandTutorial[0].SetActive(value: false);
			HandTutorial[1].SetActive(value: true);
		}
	}

	public void Restore()
	{
		InappController.RestorePurchases();
	}

	public void OnClickBuy()
	{
		AudioController.Instance.SoundButtonAllGame();
		if (GameManager.TotalCoin >= numberUpgradeWeapon[id][0])
		{
			GameManager.TotalCoin -= numberUpgradeWeapon[id][0];
			GameManager.levelUpgrade[id]++;
			texhMeshCoinUpgrade[id].text = numberUpgradeWeapon[id][GameManager.levelUpgrade[id] + 1].ToString();
			texhMeshCoinUpgrade[id].Commit();
			btnBuyWeapon.SetActive(value: false);
			SaveGameController.SaveGame();
		}
		else
		{
			OnclickbtnCoin();
		}
		if (GameManager.Tutorial == 3 && tutorialShop == 1)
		{
			GameManager.Tutorial++;
			HandTutorial[5].SetActive(value: false);
			HandTutorial[6].SetActive(value: true);
		}
	}

	public void OnClickBuyCoin(tk2dUIItem uiitem)
	{
		AudioController.Instance.SoundButtonAllGame();
		switch (a)
		{
		case 0:
			InappController.Buy("com.unimob.stickman.ghost.ninja.warrior.7000golds");
			break;
		case 1:
			InappController.Buy("com.unimob.stickman.ghost.ninja.warrior.40000golds");
			break;
		case 2:
			InappController.Buy("com.unimob.stickman.ghost.ninja.warrior.90000golds");
			break;
		case 3:
			InappController.Buy("com.unimob.stickman.ghost.ninja.warrior.200000golds");
			break;
		case 4:
			InappController.Buy("com.unimob.stickman.ghost.ninja.warrior.450000golds");
			break;
		}
		GameManager.Tutorial = 5;
	}

	public void OnclickBuyItem(tk2dUIItem uiitem)
	{
		SystemItem.SetActive(value: true);
		priceItemInDialog.text = numberPriceItem[c];
		priceItemInDialog.Commit();
		DesItemInDialog.text = DesPriceItem[c];
		DesItemInDialog.Commit();
		ImageBuyItem.SetSprite(imageItem[c]);
		if (c == 3)
		{
			CoinAnHien.SetActive(value: false);
		}
	}

	public void OnclickbtnShopWeapon()
	{
		indexbtnSHop = 0;
		checkbtnShop();
	}

	public void OnclickbtnItem()
	{
		indexbtnSHop = 1;
		btnQuipWeapon.SetActive(value: false);
		checkbtnShop();
	}

	public void OnclickbtnCoin()
	{
		indexbtnSHop = 2;
		btnQuipWeapon.SetActive(value: false);
		checkbtnShop();
	}

	public void OnclickbtnClose()
	{
		SystemUpgrade.transform.position = new Vector3(0f, 10f, 0f);
		SystemItem.SetActive(value: false);
		if (GameManager.Tutorial == 1 && tutorialShop == 2)
		{
			HandTutorial[2].SetActive(value: false);
			HandTutorial[3].SetActive(value: true);
			GameManager.Tutorial++;
			GameObject.Find("Upgradebtn").GetComponent<Collider>().enabled = false;
			GameObject.Find("btn-back").GetComponent<Collider>().enabled = true;
		}
	}

	public void OnclickUpgradeInDialog()
	{
		if (GameManager.TotalCoin >= numberUpgradeWeapon[id][GameManager.levelUpgrade[id] + 1] && GameManager.levelUpgrade[id] < 5)
		{
			GameManager.TotalCoin -= numberUpgradeWeapon[id][GameManager.levelUpgrade[id] + 1];
			GameManager.levelUpgrade[id]++;
			texhMeshCoinUpgrade[id].text = numberUpgradeWeapon[id][GameManager.levelUpgrade[id] + 1].ToString();
			texhMeshCoinUpgrade[id].Commit();
			if (GameManager.levelUpgrade[id] < 5)
			{
				ImageUpgradeNow.SetSprite(SpriteWeapon[id][GameManager.levelUpgrade[id]]);
				ImageUpgradeNext.SetSprite(SpriteWeapon[id][GameManager.levelUpgrade[id] + 1]);
				texhMeshCoinUpgradeInDialog.text = numberUpgradeWeapon[id][GameManager.levelUpgrade[id] + 1].ToString();
				texhMeshCoinUpgradeInDialog.Commit();
				texhMeshNow.text = (GameManager.levelUpgrade[id] + 1).ToString();
				texhMeshNow.Commit();
				texhMeshNext.text = (GameManager.levelUpgrade[id] + 2).ToString();
				texhMeshNext.Commit();
				if (id == 0)
				{
					texhMeshDesUpgrade.text = DesUpgrade[GameManager.levelUpgrade[id]];
					texhMeshDesUpgrade.Commit();
				}
			}
			else
			{
				SystemUpgrade.transform.position = new Vector3(0f, 10f, 0f);
			}
		}
		else if (GameManager.TotalCoin <= numberUpgradeWeapon[id][GameManager.levelUpgrade[id] + 1] && GameManager.levelUpgrade[id] < 5)
		{
			SystemUpgrade.transform.position = new Vector3(0f, 10f, 0f);
			OnclickbtnCoin();
		}
		if (GameManager.Tutorial == 1 && tutorialShop == 1)
		{
			tutorialShop++;
			HandTutorial[1].SetActive(value: false);
			HandTutorial[2].SetActive(value: true);
			GameObject.Find("btnUpgrade").GetComponent<Collider>().enabled = false;
			GameObject.Find("btnClose").GetComponent<Collider>().enabled = true;
		}
		SaveGameController.SaveGame();
	}

	public void ObclickBuyItemInDialog()
	{
		switch (c)
		{
		case 0:
			if (GameManager.numberHealth < 99 && GameManager.TotalCoin >= 1000)
			{
				GameManager.TotalCoin -= 1000;
				GameManager.numberHealth++;
			}
			else if (GameManager.numberHealth < 99 && GameManager.TotalCoin < 1000)
			{
				OnclickbtnCoin();
				SystemItem.SetActive(value: false);
			}
			break;
		case 1:
			if (GameManager.numberBigHealth < 99 && GameManager.TotalCoin >= 5000)
			{
				GameManager.TotalCoin -= 5000;
				GameManager.numberBigHealth++;
			}
			else if (GameManager.numberBigHealth < 99 && GameManager.TotalCoin < 5000)
			{
				SystemItem.SetActive(value: false);
				OnclickbtnCoin();
			}
			break;
		case 2:
			if (GameManager.Dog == 0 && GameManager.TotalCoin >= 100000)
			{
				GameManager.TotalCoin -= 100000;
				GameManager.Dog = 1;
				SystemItem.SetActive(value: false);
			}
			else if (GameManager.Dog == 0 && GameManager.TotalCoin < 100000)
			{
				SystemItem.SetActive(value: false);
				OnclickbtnCoin();
			}
			else if (GameManager.Dog == 1)
			{
				SystemItem.SetActive(value: false);
			}
			break;
		case 3:
			if (GameManager.Tinker == 0)
			{
				InappController.Buy("com.unimob.stickman.ghost.ninja.warrior.fairy");
				SystemItem.SetActive(value: false);
			}
			else if (GameManager.Tinker == 1)
			{
				SystemItem.SetActive(value: false);
			}
			break;
		}
		SaveGameController.SaveGame();
	}

	private void checkbtnShop()
	{
		for (int i = 0; i < 3; i++)
		{
			if (i == indexbtnSHop)
			{
				systemAllShop[i].SetActive(value: true);
				btnAllShopON[i].SetActive(value: true);
				btnAllShopOFF[i].SetActive(value: false);
				systemtheoShop[i].SetActive(value: true);
			}
			else
			{
				systemAllShop[i].SetActive(value: false);
				btnAllShopON[i].SetActive(value: false);
				btnAllShopOFF[i].SetActive(value: true);
				systemtheoShop[i].SetActive(value: false);
			}
		}
	}
}
